package com.ruoyi.system.controller;

import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.mybatis.core.page.PageQuery;
import com.ruoyi.common.mybatis.core.page.TableDataInfo;
import com.ruoyi.system.domain.TimeInterval;
import com.ruoyi.system.service.TimeIntervalService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;


/**
 * 时间间隔控制器
 *
 * @author Administrator
 * @date 2023/03/13
 */
@RestController
@RequestMapping("/time_interval")
@RequiredArgsConstructor
public class TimeIntervalController extends BaseController {

    private final TimeIntervalService timeIntervalService;

    /**
     * 分页消费时段
     *
     * @param timeInterval 时间间隔
     * @param pageQuery    页面查询
     * @return {@link TableDataInfo}<{@link TimeInterval}>
     */
    @GetMapping("/page")
    public TableDataInfo<TimeInterval> pageTimeInterval(TimeInterval timeInterval, PageQuery pageQuery) {
        return timeIntervalService.pageTimeInterval(timeInterval, pageQuery);
    }

    /**
     * 列表时间间隔
     *
     * @return {@link R}<{@link TimeInterval}>
     */
    @GetMapping
    public R<List<TimeInterval>> listTimeInterval() {
        return R.ok(timeIntervalService.list());
    }

}
